Dreamweaver Article

How to Develop an Online Shopping Cart (Part Two)


Table of Contents

  1. Introduction
  2. Business Logic
  3. Security and Liability
  4. Processing Credit Cards Online

Business Logic

There's really nothing complicated about understanding the business logic behind a shopping cart application. It's all pretty basic. It’s like a web store and cash register. You display your merchandise, sell stuff, and keep track of your customers and their orders. What is more involved is developing the business logic behind a cart application and then developing the database to fit, not only now, but into the future as well.

The important thing is sitting down and mapping out the business logic you will use. Ask yourself or your client questions like:

  • Who will have access to the data?
  • Will there be multiple levels of access?
  • How will you categorize the data?
  • How will you display the merchandise?
  • How will the customers search for or browse for the merchandise?
  • Once a product has orders associated with it, will you allow the product to be deleted?
  • Will you allow customer orders to be manually entered (via phone, fax, e-mail, mail, etc) or only come through the web site?
  • Once a customer has placed orders, will you allow the customer to be deleted from the database?
  • Will you create a status for active and inactive customers?
  • Will you keep track of stock?
  • Will you allow items that are out of stock show on the web, thus creating back orders?
  • How will you designate a new order from a shipped order?

As you can see, mapping out the business logic and planning the database is where you will spend a lot of your time. Your answers to these questions will not only guide the scope and structure of the database but the code and logic of the shopping cart portion of your web site.

Avoided Creating Dead Ends

About this time, you may say to yourself, "I'm a web developer, not a database programmer." Which may be true, but it’s important to accept that planning the database is every bit as important, if not more so, than developing of the site itself.

If you are going to be developing e-commerce applications, you are at least going to have to become familiar with database design. Even if someone else develops the database, you're going to have to know how it works to effectively communicate with it.

Note: To help you ease into understanding and working with databases, I highly recommend you think about getting Database Design for Mere Mortals: A Hands-On Guide to Relational Database Design, Second Edition by Michael J. Hernandez. This book is an easy read and does an excellent job of covering database design essentials.

Take your time. Every hour you spend planning out the business logic of your application you'll get back ten-fold later in saved headaches and restful nights. But what if you don't have the time? If you need to, get some help. The business logic of your site and the resulting database design is important enough that if this is not your expertise and you don't have the time to dive into it, you should get some help.

The important thing is take the time to ask the questions and work out a number of scenarios to come up with a business logic and accompanying database design that will serve you now, and grow with you. As we stated in part one of this article series, you will have to live with your database design decisions for a long time. So save yourself a lot of possible frustration and before you even open Dreamweaver and write your first line of code. Take the time to plan your database.

Now, let's take a moment to look a how your application talks to the database.

SQL… Learn it, Love It!

SQL (Structured Query Language) is a database centric programming language. SQL is basically the way all application server languages communicate with databases. I won’t go into depth about it here. Just know you'll have to take some time to at least understand SQL, if not know it.

Note: A fantastic little book on SQL is Sams Teach Yourself SQL in 10 Minutes (2nd Edition) by Ben Forta. It could possibly be the best $14.00 you'll ever spend. I use this great little reference so often that I took my copy down to the local office supply and had them cut the binding off of it and them spiral bind it so it would lay flat to the page I need. It’s never far from reach.

With a better understanding of database design and SQL, and your database all mapped out, you're ready to move forward. For more information on database design, development and SQL, visit the Database Topic Center. Now there's another very important subject to consider: Security.